package com.jyw.system.domain.vo;

import com.jyw.common.core.domain.entity.SysDictData;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 沈峻
 * @ClassName DictCacheListVo
 * @Description TODO
 * @Date 2023/8/28 15:19
 **/
@ApiModel("数据字典类型")
@Data
@NoArgsConstructor
public class DictCacheListVo {

    @ApiModelProperty("类型")
    private String type;

    @ApiModelProperty("字典数据")
    private List<DictCacheVo> data;

    public DictCacheListVo(String type, List<SysDictData> list) {
        this.type = type;
        if(!CollectionUtils.isEmpty(list)){
            this.data = list.stream().map(DictCacheVo::new).collect(Collectors.toList());
        }
    }
}
